// pages/bayi/index.js
import {
    article,
	position,
	wechat,
	user
} from "../../api/apiData"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        banner: '',
        navList: [{
                url: "/pages/npcNews/index?id=3&name=风采八一",
                src: "/images/bayi/icon1.png",
                name: "风采八一"
            },
            {
                url: "/pages/npcNews/index?id=9&name=特色工作动态",
                src: "/images/bayi/icon2.png",
                name: "特色工作动态"
            },
            {
                url: "/pages/npcNews/index?id=10&name=活动风采",
                src: "/images/bayi/icon3.png",
                name: "活动风采"
            },
            {
                url: "/pages/npcNews/index?id=11&name=活动通知",
                src: "/images/bayi/icon4.png",
                name: "活动通知"
            },
            {
                url: "/pages/people/index",
                src: "/images/bayi/icon5.png",
                name: "成员名单"
            },
            {
                url: "/pages/suggest/list",
                src: "/images/bayi/icon6.png",
                name: "民情民意"
            }
        ],
        loadMoreText: '加载中...', //底部文字
		list: [],
		banner: '',
        banner2: '',
        showNav: true,
        showImg: false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
		this.getList(1)
        position.content.detail({
            position_id: 4
        }, res => {
            if (res.code == 1) {
                this.setData({
                    banner: res.data.path
                })
            }
        })
    },
    toNew() {
		wx.navigateTo({
			url: '/pages/npcNews/index?id=9&name=特色工作动态',
		})
	},
	// 获取列表
	getList(page) {
		var that = this
		article.lists({
			page: page,
			size: 10,
			channel_id: 9
		}, res => {
			that.setData({
				total: res.data.total
			})
			if (res.data.list.length > 0) {
				that.setData({
					list: that.data.list.concat(res.data.list) //合并数据
				})
				if (11 > res.data.list.length > 0) {
					that.setData({
						loadMoreText: '' //没有更多了
					})
				}

			} else {
				if (page !== 1) {
					that.setData({
						loadMoreText: '暂无数据'
					})
				} else {
					that.setData({
						list: [],
						loadMoreText: '暂无数据'
					})
				}
			}
			wx.stopPullDownRefresh();
		})
	},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {
		pageNum1 = 1
		this.setData({
			list: [],
		});
		this.getList(1)
	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {
		pageNum1 += 1;
		this.getList(pageNum1)
	},

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})